package cn.hznc.controller.configure;

import cn.hznc.aspect.BusinessType;
import cn.hznc.aspect.Log;
import cn.hznc.controller.service.configure.ConfigureService;
import cn.hznc.domain.request.configure.AddComReq;
import cn.hznc.domain.request.life.ToolUsageReportReq;
import cn.hznc.domain.response.ResponseBody;
import cn.hznc.exception.ToolScheduleException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：Administrator
 * @Date：2023/11/9 11:46
 */
@RestController
@Slf4j
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/configure")
public class ConfigureController{

    @Autowired
    private ConfigureService configureService;

    @RequestMapping(value = "/addCom", method = RequestMethod.POST)
    @Log(title = "新增扫码枪COM口" , businessType = BusinessType.INSERT)
    public ResponseBody addCom(@RequestBody AddComReq addComReq) {
        return ResponseBody.success(configureService.addCom(addComReq));
    }

    @RequestMapping(value = "/queryCom", method = RequestMethod.GET)
    public ResponseBody queryCom(@RequestParam("com") String com) {
        return ResponseBody.success(configureService.queryCom(com));
    }

    @RequestMapping(value = "/deleteCom", method = RequestMethod.GET)
    @Log(title = "删除扫码枪COM口" , businessType = BusinessType.DELETE)
    public ResponseBody deleteCom(@RequestParam("id") Integer id) {
        return ResponseBody.success(configureService.deleteCom(id));
    }
//
//    @RequestMapping(value = "/deleteCom", method = RequestMethod.POST)
//    public ResponseBody toolUsageReport(@RequestBody ToolUsageReportReq toolUsageReportReq) {
//        try {
//            return ResponseBody.success(toolLieService.toolUsageReport(toolUsageReportReq));
//        } catch (ToolScheduleException e) {
//            return ResponseBody.error(e.getCode() , e.getMsg());
//        }
//    }
}
